package edu.zhuoxun.blogserver.map;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import edu.zhuoxun.blogserver.entity.Role;
import edu.zhuoxun.blogserver.entity.User;
import edu.zhuoxun.blogserver.entity.UserRoles;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {
    @Delete("delete from user_role where user_id = #{id}")
    void deleteHasRoles(User user);
    @Insert("<script> insert into user_role values " +
            "<foreach collection='hasRoles' item='role' index='index' separator=','>" +
            "(#{user.id},#{role.id})" +
            "</foreach>" +
            "</script>")
    void insertHasRoles(UserRoles userRoles);
}
